<?php
// +----------------------------------------------------------------------
// | YotakuCMS
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.yotaku.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Creatint <creatint@163.com> 
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {
    public function _initialize()
    {
        parent::_initialize(); // TODO: Change the autogenerated stub
    }

    //系统首页
    public function index(){
        // 已登录，判断用户类型，进行跳转
        if('dealer' == USER_TYPE){
            header('Location:'.U('Home/Dealer/index'));
        }elseif('agent' == USER_TYPE){
            header('Location:'.U('Home/Agent/index'));
        }elseif('tmall' == USER_TYPE){
            header('Location:'.U('Home/Tmall/index'));
        }
        exit;
    }

    public function search(){
        $controller = $_REQUEST['controller'];
        $action = $_REQUEST['action'];
        $query = [];
        foreach( $_REQUEST as $k=>$v ) {
            switch($k){
                case 'dealer_name':
                    $query['dealer_name'] = $_REQUEST['dealer_name'];
                    break;
                case 'plate_number':
                    $query['plate_number'] = $_REQUEST['plate_number'];
                    break;
                case 'status':
                    $query['status'] = $_REQUEST['status'];
                    break;
                case 'username':
                    $query['username'] = $_REQUEST['username'];
                    break;
                case 'city':
                    $query['city'] = $_REQUEST['city'];
                    break;

            }
        }
        redirect(U($controller.'/'.$action,$query));
    }

}